//
//  NavigationTransiitionVC.m
//  Home
//
//  Created by 曹连华 on 2019/7/3.
//  Copyright © 2019 曹连华. All rights reserved.
//

#import "NavigationTransiitionVC.h"
#import <ServiceCode/ServiceCode.h>
#import <Masonry/Masonry.h>
@interface NavigationTransiitionVC () {
    CGPoint _beginPoint;
}

@end

@implementation NavigationTransiitionVC

+ (void)load {
    RouterVO *vo = [RouterVO new];
    vo.tab = NO;
    vo.createdType = PBRouteObjectCreateByCode;
    vo.className = NSStringFromClass(self);
    vo.keyInfo = @"转场动画二级页面";
    [[Router sharedInstance]registerRouterVO:vo withKey:@"navigationtransiition"];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self setTitle:@"转场动画第二页面"];
    [self initUI];
    
}
- (void)initUI {
    
    UIButton *btn1 = [[UIButton alloc]initWithFrame:CGRectZero];
    [btn1 setTitle:@"pop" forState:UIControlStateNormal];
    btn1.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [btn1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn1 addTarget:self action:@selector(btn1Action:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn1];
    
    [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(50);
        make.top.mas_equalTo(150);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(30);
    }];
    
    
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    NSLog(@" - %@",[Router sharedInstance].currentNC.delegate);
    UITouch *touch = [touches anyObject];
    _beginPoint = [touch locationInView:self.view];

}

- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    
    //2.获取手指当前位置
    CGPoint currentPoint = [touch locationInView:self.view];
    CGFloat dx = (currentPoint.x - _beginPoint.x)/UIScreen.width;
    CGFloat dy = (currentPoint.y - _beginPoint.y)/UIScreen.height;
    NSLog(@" dx = %f dy =  %f ",dx,dy);


}

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    //2.获取手指当前位置
    CGPoint currentPoint = [touch locationInView:self.view];
    CGFloat dx = (currentPoint.x - _beginPoint.x)/UIScreen.width;
}

- (void)btn1Action:(UIButton *)btn {
    [self.navigationController popViewControllerAnimated:YES];
    
}
@end
